import java.awt.List;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Console;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;

import javax.media.nativewindow.util.SurfaceSize;

import org.jzy3d.chart.Chart;
import org.jzy3d.chart.ChartLauncher;
import org.jzy3d.colors.Color;
import org.jzy3d.colors.ColorMapper;
import org.jzy3d.colors.colormaps.ColorMapRainbow;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.maths.Range;
import org.jzy3d.plot3d.builder.Builder;
import org.jzy3d.plot3d.builder.concrete.OrthonormalGrid;
import org.jzy3d.plot3d.primitives.MultiColorScatter;
import org.jzy3d.plot3d.primitives.Point;
import org.jzy3d.plot3d.primitives.Polygon;
import org.jzy3d.plot3d.primitives.Shape;


public class Plotter {
	public static void main(String[] args) throws IOException {
		FileReader fr = new FileReader("src/songs.txt");
		BufferedReader br = new BufferedReader(fr);
		String line;
		String[][] xyz = new String[70000][3];
		int count = 0;
		while((line = br.readLine()) != null) {
			count++;
			xyz[count-1] = line.split(" ");
		}
		br.close();
		
		Coord3d[] points = new Coord3d[count];
		double x, y, z;
		for (int i=0; i<count; i++) {
			try {
				x = Double.parseDouble(xyz[i][0]);
				y = Double.parseDouble(xyz[i][1]);
				z = Double.parseDouble(xyz[i][2]);
				points[i] = new Coord3d(x, y, z);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		// create drawable scatter with colormap
		MultiColorScatter scatter = new MultiColorScatter(points, new ColorMapper(new ColorMapRainbow(), 0f, 1f));
		
		// create char and add scatter
		Chart chart = new Chart();
		chart.getAxeLayout().setMainColor(Color.WHITE);
		chart.getView().setBackgroundColor(Color.BLACK);
		chart.getScene().add(scatter);
		ChartLauncher.openChart(chart);
	}
}
